﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong.WorkXml;
using Tong;
using Tong.Fy;
public partial class Ascx_Fast_Menu : System.Web.UI.UserControl
{

    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();
    /// <summary>
    /// 分页类 調用分頁函數
    /// </summary>
    public FenYe FY = new FenYe();


    protected void Page_Load(object sender, EventArgs e)
    {
        Fast_menu_text.Text = FastXmlMenu(Server.MapPath(Tong.TongUse.SysPath + "inc/Xml/Page_Menu.xml"), TextData.CurrentPage);
    }

    /// <summary>
    /// 返回数据页面快捷菜单 FastXmlMenu
    /// </summary>
    /// <param name="fileName">保存有XMLMenu菜单的XML文件在服务器上的决对路径</param>
    /// <param name="Current_Page">当前页面</param>
    /// <returns></returns>
    public String FastXmlMenu(String fileName, String Current_Page)//Current_Dir为当前页面
    {
        string[] MenuText = "".Split(',');
        string[] MenuHtml;
        string OutHtml = "";//返回HTML
        MyDt = Tong.WorkXml.OperateXmlByDataSet.GetDataSetByXml(Tong.TongUse.SysPath + "inc/Xml/Page_Menu.xml").Tables[0];
        try
        {
            for (int i = 0; i < MyDt.Rows.Count; i++)
            {
                if (MyDt.Rows[i]["pagename"].ToString() == Current_Page)//看看有没有这个记录
                {
                    MenuText = MyDt.Rows[i]["menu"].ToString().Split('^');//以"^"折分网页菜单
                    // Response.Write(MyDt.Rows[i]["menu"].ToString());
                }



            }

            for (int j = 0; j < MenuText.Length; j++)
            {
                MenuHtml = MenuText[j].Split('|');//以"|"折分菜单得到菜单名与联接路径
                // Response.Write(MenuText[j].ToString());
                //OutHtml+= MenuHtml[0].ToString();
                OutHtml += "<a Class = 'link1' href=\"javascript:window.location.href=\'" + MenuHtml[1].Trim().Replace("~/",Abs_Path) + "\'\" title='" + MenuHtml[0] + "'> " + MenuHtml[0] + " </a>";
            }

        }
        catch
        {
            return OutHtml;
        }
        return OutHtml;
    }

}
